home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sun4c
/
archive
/
tcltk.z
/
tcltk
/
man
/
catn
/
foreach.n
< prev
next >
Wrap
Text File
|
1994-09-20
|
1KB
|
67 lines
foreach(n) Tcl Built-In Commands
_________________________________________________________________
NAME
foreach - Iterate over all elements in a list
SYNOPSIS
foreach _v_a_r_n_a_m_e _l_i_s_t _b_o_d_y
_________________________________________________________________
DESCRIPTION
In this command _v_a_r_n_a_m_e is the name of a variable, _l_i_s_t is a
list of values to assign to _v_a_r_n_a_m_e, and _b_o_d_y is a Tcl
script. For each element of _l_i_s_t (in order from left to
right), foreach assigns the contents of the field to _v_a_r_n_a_m_e
as if the lindex command had been used to extract the field,
then calls the Tcl interpreter to execute _b_o_d_y. The break
and continue statements may be invoked inside _b_o_d_y, with the
same effect as in the for command. Foreach returns an empty
string.
KEYWORDS
foreach, iteration, list, looping
Tcl 1